package com.wangp.mywrite.a_jvm.ch04;

public class MovingAverage {
    private int count = 0;
    private double sum = 0.0D;
    public void submit(double value){
        this.count ++;
        this.sum += value;
    }
    public double getAvg(){
        if(0 == this.count){ return sum;}
        return this.sum/this.count;
    }
}
/*
 * public class MovingAverage {
 *     private int count = 0;
 *     private double sum = 0.0D;
 *
 *     public MovingAverage() {
 *     }
 *
 *     public void submit(double value) {
 *         ++this.count;
 *         this.sum += value;
 *     }
 *
 *     public double getAvg() {
 *         return 0 == this.count ? this.sum : this.sum / (double)this.count;
 *     }
 * }
 */
